<?php

namespace api\modules\v1\controllers\member;

use api\controllers\UserAuthController;
use common\helpers\ResultHelper;
use common\models\member\LevelOrder;
use Yii;

/**
 * 提现账号
 *
 * Class BankAccountController
 * @package api\modules\v1\controllers\member
 * @author  
 */
class LevelOrderController extends UserAuthController
{
    /**
     * @var LevelOrder
     */
    public $modelClass = LevelOrder::class;

    public function actionBuy()
    {
        $level = Yii::$app->request->post('level');
        $member_id = Yii::$app->user->identity->member_id;
        $model = new $this->modelClass;
        $model->member_id = $member_id;
        $model->after_level = $level;
        if($model->buyLevel()){
            return true;
        }else{
            return ResultHelper::json(422, $this->getError($model));
        }
        
    }
}